<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitepage
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: index.tpl 2011-05-05 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
?>
<?php
  $this->headLink()
  	->prependStylesheet($this->seaddonsBaseUrl().'/application/modules/Sitepage/externals/styles/sitepage-tooltip.css');
?>
<?php $enableBouce=Engine_Api::_()->getApi('settings', 'core')->getSetting('sitepage.map.sponsored', 1); 
$recently_randum_isthumb = Zend_Registry::isRegistered('sitepage_is_random_thumb') ? Zend_Registry::get('sitepage_is_random_thumb') : null;
$currency = Engine_Api::_()->getApi('settings', 'core')->getSetting('payment.currency', 'USD');?>

<div class="layout_core_container_tabs">
<div class="tabs_alt tabs_parent">
  <ul id="main_tabs"> 
    <?php if ($this->tab1_show == 1): ?>
      <?php if ($this->active_tab1 == 1): ?>
        <li class = 'active' id = 'sitepage_home_page_tab1' >
      <?php else : ?>
        <li class = '' id = 'sitepage_home_page_tab1' >
      <?php endif; ?>
	      <?php
	      if ($this->tab2_show == 1 || $this->tab3_show == 1 || $this->tab4_show == 1 || $this->tab5_show == 1): ?>
	        <a href='javascript:void(0);'  onclick="showListSitepage('Recently Posted')"><?php echo $this->translate("Recent") ?></a>
	     <?php elseif ($this->tab2_show != 1 && $this->tab3_show != 1 && $this->tab4_show != 1 && $this->tab5_show != 1):
	        echo $this->translate("Recent");
	      endif;
	      ?>
      </li>
    <?php endif; ?>
    <?php if ($this->tab2_show == 1): ?>
      <?php if ($this->active_tab2 == 1): ?>
      <li class = 'active' id = 'sitepage_home_page_tab2' >
      <?php else : ?>
      <li class = '' id = 'sitepage_home_page_tab2' >
      <?php endif; ?>
        <?php
        if (( $this->tab1_show == 1 || $this->tab3_show == 1 ||$this->tab4_show == 1) || $this->tab5_show == 1): ?>
         <a href='javascript:void(0);' onclick="showListSitepage('Most Viewed')"> <?php echo $this->translate("Most Popular"); ?></a>
      <?php  elseif ($this->tab1_show != 1 && $this->tab3_show != 1 && $this->tab4_show != 1 && $this->tab5_show != 1):
          echo $this->translate("Most Popular");
        endif;
        ?>
      </li>
    <?php endif; ?>
    <?php if ($this->tab3_show == 1): ?>
      <?php if ($this->active_tab3 == 1) : ?>
      <li class = 'active' id = 'sitepage_home_page_tab3' >
      <?php else : ?>
      <li class = '' id = 'sitepage_home_page_tab3' >
      <?php endif; ?>
        <?php
        if ($this->tab2_show == 1 || $this->tab1_show == 1 || $this->tab4_show == 1 || $this->tab5_show == 1): ?>
          <a href='javascript:void(0);' onclick="showListSitepage('Random')"> <?php echo  $this->translate("Random"); ?></a>
       <?php elseif ($this->tab2_show != 1 && $this->tab1_show != 1 && $this->tab4_show != 1 && $this->tab5_show != 1):
          echo $this->translate("Random");
        endif;
        ?>
      </li>
    <?php endif; ?>
      <?php if ($this->tab4_show == 1): ?>
      <?php if ($this->active_tab4 == 1) : ?>
      <li class = 'active' id = 'sitepage_home_page_tab4' >
      <?php else : ?>
      <li class = '' id = 'sitepage_home_page_tab4' >
      <?php endif; ?>
        <?php
        if ($this->tab2_show == 1 || $this->tab1_show == 1 || $this->tab3_show == 1 || $this->tab5_show == 1): ?>
          <a href='javascript:void(0);' onclick="showListSitepage('Featured')"> <?php echo  $this->translate("Featured"); ?></a>
       <?php elseif ($this->tab2_show != 1 && $this->tab1_show != 1 && $this->tab3_show != 1 &&  $this->tab5_show != 1 ):
          echo $this->translate("Featured");
        endif;
        ?>
      </li>
    <?php endif; ?>
      <?php if ($this->tab5_show == 1): ?>
      <?php if ($this->active_tab5 == 1) : ?>
      <li class = 'active' id = 'sitepage_home_page_tab5' >
      <?php else : ?>
      <li class = '' id = 'sitepage_home_page_tab5' >
      <?php endif; ?>
        <?php
        if ($this->tab2_show == 1 || $this->tab1_show == 1 || $this->tab3_show == 1 || $this->tab4_show == 1): ?>
          <a href='javascript:void(0);' onclick="showListSitepage('Sponosred')"> <?php echo  $this->translate("Sponsored"); ?></a>
       <?php elseif ($this->tab2_show != 1 && $this->tab1_show != 1 && $this->tab3_show != 1 && $this->tab4_show != 1):
          echo $this->translate("Sponsored");
        endif;
        ?>
      </li>
    <?php endif; ?>
   <?php if (($this->list_view && $this->grid_view) || ($this->map_view && $this->grid_view) || ($this->list_view && $this->map_view)): ?>
    <?php  if( $this->enableLocation && $this->map_view): ?>
      <?php  $latitude=Engine_Api::_()->getApi('settings', 'core')->getSetting('sitepage.map.latitude', 0); ?>
      <?php  $longitude=Engine_Api::_()->getApi('settings', 'core')->getSetting('sitepage.map.longitude', 0); ?>
      <?php  $defaultZoom=Engine_Api::_()->getApi('settings', 'core')->getSetting('sitepage.map.zoom', 1); ?>
	    <li class="sitepage_show_tooltip_wrapper sitepage_view_map fright">
				<div class="sitepage_show_tooltip"><?php echo $this->translate("Map View") ?></div>
      	<img src='application/modules/Sitepage/externals/images/map_icon.png' onclick="rswitchviewPage(2)" align="left" alt="" class="select_view" />
	    </li>
    <?php endif;?>
    <?php  if( $this->grid_view): ?> 
    <li class="sitepage_show_tooltip_wrapper sitepage_view_grid fright">
			<div class="sitepage_show_tooltip"><?php echo $this->translate("Grid View") ?></div>
      <img src='application/modules/Sitepage/externals/images/grid.png' onclick="rswitchviewPage(1)" align="left" alt="" class="select_view" />
    </li> 
    <?php endif;?>
    <?php  if( $this->list_view): ?>
    <li class="sitepage_show_tooltip_wrapper sitepage_view_list fright">
      <div class="sitepage_show_tooltip"><?php echo $this->translate("List View") ?></div>
      <img src='application/modules/Sitepage/externals/images/list.png' onclick="rswitchviewPage(0)" align="left" alt="" class="select_view" />
    </li>
    <?php endif;?>
   <?php endif;?>
  </ul>
</div>
<div id="dynamic_app_info_page">
<?php
	if( !empty($recently_randum_isthumb) ) {
		include_once APPLICATION_PATH . '/application/modules/Sitepage/views/scripts/_recently_popular_random_page.tpl';
	}
?>
 </div>
 </div>
<script type="text/javascript" >
	function rswitchviewPage(flage){
	if(flage==2){
      if($('rmap_canvas_view_page')){
			$('rmap_canvas_view_page').style.display='block';
			google.maps.event.trigger(rmap_page, 'resize');
			rmap_page.setZoom(<?php echo $defaultZoom; ?> );
			rmap_page.setCenter(new google.maps.LatLng(<?php echo $latitude; ?>,<?php echo $longitude; ?>));
      }
			if($('rgrid_view_page'))
      $('rgrid_view_page').style.display='none';
     if($('rimage_view_page'))
		$('rimage_view_page').style.display='none';
		}else if(flage==1){
     if($('rmap_canvas_view_page'))
		$('rmap_canvas_view_page').style.display='none';
    if($('rgrid_view_page'))
		$('rgrid_view_page').style.display='none';
    if($('rimage_view_page'))
		$('rimage_view_page').style.display='block';
		}else{
    if($('rmap_canvas_view_page'))
		$('rmap_canvas_view_page').style.display='none';
    if($('rgrid_view_page'))
		$('rgrid_view_page').style.display='block';
    if($('rimage_view_page'))
		$('rimage_view_page').style.display='none';
		}
	}
</script>
<script type="text/javascript">

/* moo style */
window.addEvent('domready',function() {
	if($('rimage_view_page')){
  showtooltipPage();
  }
   <?php if( $this->enableLocation && $this->map_view): ?>
    rinitializePage();
    <?php endif; ?>
 rswitchviewPage(<?php echo $this->defaultView ?>);
});

var showtooltipPage = function (){
  if($('rimage_view_page')){
  //opacity / display fix
	$$('.sitepage_tooltip').setStyles({
		opacity: 0,
		display: 'block'
	});
	//put the effect in place
	$$('.jq-sitepage_tooltip li').each(function(el,i) {
		el.addEvents({
			'mouseenter': function() {
				el.getElement('div').fade('in');
			},
			'mouseleave': function() {
				el.getElement('div').fade('out');
			}
		});
	});
  }
}
</script>

<script type="text/javascript">

   var showListSitepage = function (tabshow) {   
     if($('sitepage_home_page_tab1'))
        $('sitepage_home_page_tab1').erase('class');
      if($('sitepage_home_page_tab2'))
        $('sitepage_home_page_tab2').erase('class');
      if($('sitepage_home_page_tab3'))
        $('sitepage_home_page_tab3').erase('class');
       if($('sitepage_home_page_tab4'))
        $('sitepage_home_page_tab4').erase('class');
        if($('sitepage_home_page_tab5'))
        $('sitepage_home_page_tab5').erase('class');

    if (tabshow == "Recently Posted") {     
      if($('sitepage_home_page_tab1'))
        $('sitepage_home_page_tab1').set('class', 'active');
    }
    else if (tabshow == "Most Viewed") {   
      if($('sitepage_home_page_tab2'))
        $('sitepage_home_page_tab2').set('class', 'active');
    }
    else if(tabshow == "Random") {     
      if($('sitepage_home_page_tab3'))
        $('sitepage_home_page_tab3').set('class', 'active');
    }else if(tabshow == "Featured") {    
      if($('sitepage_home_page_tab4'))
        $('sitepage_home_page_tab4').set('class', 'active');
    }else if(tabshow == "Sponosred") {     
      if($('sitepage_home_page_tab5'))
        $('sitepage_home_page_tab5').set('class', 'active');
    }

   if($('dynamic_app_info_page') != null) {

      $('dynamic_app_info_page').innerHTML = '<center><img src="application/modules/Sitepage/externals/images/loader.gif" class="sitepage_tabs_loader_img" /></center>';
    }

    var request = new Request.HTML({
      'url' : '<?php echo $this->url(array(), 'sitepage_ajaxhomelist', true) ?>',
      'data' : {
        'format' : 'html',
        'task' : 'ajax',
        'tab_show' : tabshow

      },
      onSuccess : function(responseTree, responseElements, responseHTML, responseJavaScript) {
        $('dynamic_app_info_page').innerHTML = responseHTML;
        
        showtooltipPage();
        <?php if( $this->enableLocation && $this->map_view): ?>
        rinitializePage();
        <?php endif; ?>
         rswitchviewPage(<?php echo $this->defaultView ?>);
      }
    });

    request.send();
  }
</script>
<style type="text/css">
  #rmap_canvas_page {
    width: 100% !important;
    height: 400px;
    float: left;
  }
  #rmap_canvas_page > div{
    height: 300px;
  }
  #infoPanel {
    float: left;
    margin-left: 10px;
  }
  #infoPanel div {
    margin-bottom: 5px;
  }
</style>